package com.xiyu.service.controller.admin.area;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassListQueryOutput;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassSingleGetOutput;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassUpdateInput;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassCreateInput;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassPageQueryOutput;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.area.OfficeAreaClassService;

@Tag(name = "办公区分类")
@RestController
@RequestMapping("/area/office-area-class")
@Validated
public class OfficeAreaClassController {

    @Resource
    private OfficeAreaClassService officeAreaClassService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询办公区")
    @PreAuthorize("@ss.hasPermission('officeArea:class:query')")
    public CommonResult<PageResult<OfficeAreaClassPageQueryOutput>> pageQuery(@Valid OfficeAreaClassPageQueryInput inputVO) {
        return success(officeAreaClassService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增办公区分类")
    @PreAuthorize("@ss.hasPermission('officeArea:class:create')")
    public CommonResult<Long> create(@Valid @RequestBody OfficeAreaClassCreateInput inputVO) {
        return success(officeAreaClassService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新办公区分类")
    @PreAuthorize("@ss.hasPermission('officeArea:class:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody OfficeAreaClassUpdateInput inputVO) {
        return success(officeAreaClassService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个办公区分类")
    @Parameter(name = "id", description = "办公区分类主键ID", example = "")
    public CommonResult<OfficeAreaClassSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(officeAreaClassService.singleGet(id));
    }

    @GetMapping("/list-query")
    @Operation(summary = "查询办公区分类")
    public CommonResult<List<OfficeAreaClassListQueryOutput>> listQuery() {
        return success(officeAreaClassService.listQuery());
    }

}
